package com.wushi.lenovo.asia5b.app_di.goods.presenter;

import com.mvp.base.BasePresenter;
import com.mvp.base.model.ResultModel;
import com.wushi.lenovo.asia5b.app_di.goods.mvpview.PayActivityView;
import com.wushi.lenovo.asia5b.app_http.ApiService;
import com.wushi.lenovo.asia5b.app_model.credit.MemberBlanceModel;
import com.wushi.lenovo.asia5b.app_model.other.UserInfo;

import javax.inject.Inject;

import io.reactivex.Observable;
import retrofit2.Retrofit;

/**
 * Created by zhangyuncai on 2020/3/4.
 */
public class PayActivityPresenter extends BasePresenter<PayActivityView> {

    ApiService apiService;

    @Inject
    public PayActivityPresenter(Retrofit retrofit) {
        apiService = retrofit.create(ApiService.class);
    }

    public void getMemberBalance() {
        Observable<ResultModel<MemberBlanceModel>> observable = apiService.getMemberBalance(UserInfo.getMemberId());
        baseSubscribe(observable, resultModel -> {
            if (resultModel.isSuccess() && resultModel.getData() != null) {
                getView().getMemberBalanceResult(resultModel.getData());
            }
        });
    }

}